const Router = require('koa-router')
const router = new Router();
const login = require("./login")
const register = require("./register")
const info = require("./info")
const upload = require("./upload")
const article = require("./article")
const namelist = require("./namelist")
const forgetPassword = require("./forgetPassword")
const {query} = require("../../config")

 router.get('/',async ctx =>{
    // let result = await new Promise((resolve, reject)=>{
    //     query("select * from user",(err, row)=>{
    //         console.log(err, row)
    //         if(err){
    //             reject(err)
    //         }
    //         resolve(row)
    //     })
    // })
    ctx.body = '管理系统'
})

router.get("/login", async ctx => {
    ctx.body = "管理系统登录接口"
})

router.use("/login",login.routes(),login.allowedMethods())
router.use("/register",register.routes(),register.allowedMethods())
router.use("/info",info.routes(),info.allowedMethods())
router.use("/upload",upload.routes(),upload.allowedMethods())
router.use("/article",article.routes(),article.allowedMethods())
router.use("/namelist",namelist.routes(),namelist.allowedMethods())
router.use("/forgetPassword",forgetPassword.routes(),forgetPassword.allowedMethods())

module.exports = router